import request from '@/utils/request'
import { getToken } from '@/utils/token'


export function loginApi (loginForm) {
    return request({
    method:'POST',
    url:'/user/login',
    data:loginForm
  })
}
export function registerApi(registerForm) {
  return request({
    method:'POST',
    url:'/user/register',
    data:registerForm
  })
}

export function changeApi (changeObj) {
  const token = getToken()
  return request({
    method:'POST',
    url:'/user/changepassword',
    data:changeObj,
    headers:{
      'Access-Token':token
    }
  })
}

export function getUserListApi (pageSize,page) {
  const token = getToken()
  return request({
    method:'GET',
    url:'user/getuserlist',
    params:{pageSize,page},
    headers:{
      'Access-Token':token
    }
  })
}


// 删除用户
export function deleteUsers (ids) {
  const token = getToken()
  return request({
    method:'POST',
    url:'user/deleteuserbyids',
    data:ids,
    headers:{
      'Access-Token':token
    }
  })
}

// 修改用户信息
export function modifyUser(user) {
  const token = getToken()
  return request({
    method:'POST',
    url:'user/modifyuser',
    data:user,
    headers:{
      'Access-Token':token
    }
  })
}

// 根据条件查找用户
export function searchUser(user) {
  const token = getToken()
  return request({
    method:'POST',
    url:'user/searchuser',
    data:user,
    headers:{
      'Access-Token':token
    }
  })
}

// 获取老师列表
export function getTeacherListApi() {
  const token = getToken()
  return request({
    method:'GET',
    url:'user/getTeacherList',
    headers:{
      'Access-Token':token
    }
  })
}


//获取老师报表列表
export function getTeacherHoursStatisticsApi(year) {
  const token = getToken()
  return request({
    method: 'GET',
    url: 'user/getTeacherHoursStatistics',
    params: {
      year
    },
    headers :{
      'Access-Token':token
    }
  })
}


// 得到用户信息
export function getUserInfoByIdApi(id) {
  const token = getToken()
  return request({
    method: 'GET',
    url: 'user/getUserInfo',
    params: {
      id
    },
    headers: {
      'Access-Token':token
    }
  })
}
